﻿using BCCommon;
using BCData.Sim.Admin.AdminOperationRecord;
using BCDto.Sim.Admin.AdminOperationRecord;
using BCService.Utils;
using System;
using System.Collections.Generic;
using System.Text;

namespace BCService.Sim.Admin.AdminOperationRecord
{
    public class AdminOperationRecordService : IAdminOperationRecordService
    {
        protected readonly IAdminOperationRecordData adminOperationRecordData;

        public AdminOperationRecordService(IAdminOperationRecordData adminOperationRecordData)
        {
            this.adminOperationRecordData = adminOperationRecordData;
        }

        public void Create(string operationName, string content, long adminId, string loginName, string fullname, int companyId)
        {
            this.adminOperationRecordData.Create(operationName, content, adminId, loginName, fullname, companyId);
        }

        public AdminOperationRecordDto GetAdminOperationRecord(string adminOperationRecordId)
        {
            var entity = this.adminOperationRecordData.GetAdminOperationRecord(adminOperationRecordId);

            return entity.As<AdminOperationRecordDto>();
        }

        public PageableList<AdminOperationRecordDto> GetAdminOperationRecords(int index, int size, string operationName, long? adminId, DateTime? startDate, DateTime? endDate, int? companyId)
        {
            int dataCount;

            var list = this.adminOperationRecordData.GetAdminOperationRecords(index, size, out dataCount, operationName, adminId, startDate, endDate, companyId);

            return new PageableList<AdminOperationRecordDto>
            {
                Count = dataCount,
                Items = list.As<IEnumerable<AdminOperationRecordDto>>()
            };
        }
    }
}
